package cn.tedu.store.mapper;

import cn.tedu.store.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
    /**
     * 处理商品信息的持久层接口
     */
    @Mapper
    public interface ProductMapper {
        /**
         * 查询上架的优先级最高的4条记录
         * @return Product对象集合
         */
        @Select("select id, category_id as categoryId, item_type as itemType, title, sell_point as sellPoint, price, num, image, status, priority from t_product where status=1 order by priority desc limit 0,4")
        List<Product> findHotList();

        /**
         * 查询单个商品记录
         * @return Product对象
         */
        @Select("select id, category_id as categoryId, item_type as itemType, title, sell_point as sellPoint, price, num, image, status, priority from t_product where id=#{id}")
        Product findById(Integer id);
    }

